<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/stype.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <form class="layui-form" action="{{url('admin/roles/'.$data->id)}}" method="post">
        {{ csrf_field() }}
        {{ method_field("put") }}
        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-inline">
                <input type="text" name="name" value="{{ $data->name }}" required lay-verify="required" placeholder="请输入名称" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">只能输入英文</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">显示名称</label>
            <div class="layui-input-inline">
                <input type="text" name="display_name" value="{{ $data->display_name }}" required lay-verify="required" placeholder="请输入显示名称" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">用于显示界面</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">权限选择</label>
            <div class="layui-input-block">
                @foreach($permissions as $v)
                    @if(permission_role($v->id,$data->id))
                        <input type="checkbox" name="permissions[]" value="{{ $v->id }}" title="{{$v->display_name}}" checked>
                        @else
                        <input type="checkbox" name="permissions[]" value="{{ $v->id }}" title="{{$v->display_name}}" >
                    @endif
                @endforeach
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">名称描述</label>
            <div class="layui-input-block">
                <textarea name="description" placeholder="请输入名称描述" class="layui-textarea">{{ $data->description }}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.min.js"></script>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){

        });
    });
</script>
</body>
</html>